<? header("Content-Type: text/html,charset=UTF-8"); ?>

<html>
<head>
	<title>Create Poll</title>
	<meta charset="utf-8">
	<link rel="shortcut icon" href="images/favicon.ico">
</head>

<style type="text/css">
.require{
	height:20px;
	color:#FF0000;
	padding-left:5px;
	padding-right:5px;
	font-size:12px;
	line-height:15px;
	width:100px;
	float:none;
}
.fset{ width: 400px; }
textarea{ resize: none; }
</style>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">


$(document).ready(function(){

	$("#btnSubmit").click(function(){
		var form = $("#frmCreatePoll");
		var method = $(form).attr("method")
		var action = $(form).attr("action");
		var content = $(form).serialize();
		var url = action+"?"+content;

	   //	if(chkForm()){
			$.ajax({
				type: method,
				url: action,
				cache: false,
				data: content,
				dataType: "html",
				statusCode: {
				    	404: function() {
				      		alert("page not found");
					}
				},
				success: function(){
					$(window.location).attr("href", url);
				}
			});

	  //	}

	});

});

/*function chkForm(){
	$(":input + span.require").remove();
	$(":input").each(function(){
		$(this).each(function(){
			if($(this).val()==""){
				$(this).after("<span class=require><<- Require</span>");
			}
		});
	});
	if($(":input").next().is(".require")==false){
		return true;
	}else{
		$(".require").fadeOut(5000);
		return false;
	}
} */

</script>

<body>


	<form id="frmCreatePoll" name="frmCreatePoll" method="post" action="create_poll.php">
		<fieldset class="fset"><legend>Create Poll :</legend>

			<table>
				<tr>
					<td>Poll name : </td>
					<td><input type="text" name="pollName" id="pollName" /></td>
				</tr>
				<tr>
					<td valign="top">Description : </td>
					<td><textarea id="desc" name="desc" rows="3" cols="20"></textarea></td>
				</tr>
				<tr>
					<td>Occupation : </td>
					<td><input type="text" name="occupation" id="occupation" /></td>
				</tr>
				<tr>
					<td>Age : </td>
					<td><input type="text" name="age" id="age" /></td>
				</tr>
				<tr>
					<td>Sex : </td>
					<td>
						<select name="sex">
                            <option value="1" selected="selected">None</option>
							<option value="2">Male</option>
							<option value="3">Female</option>
						</select>
					</td>
				</tr>
				<tr>
					<td valign="top">Province : </td>
					<td><textarea id="addr" name="addr" rows="3" cols="20"></textarea></td>
				</tr>
				<tr>
				<td></td>
				<td><input id="btnSubmit" name="btnSubmit" type="button" value="Next >>"></td>
				</tr>
			</table>


		</fieldset>
	</form>
</body>
</html>
